# !/usr/bin/env python
# encoding: utf-8

"""
file: run.py.py
time: 2019/6/20 11:42
Author: twy
contact: 19983195362
des: 淘宝爬虫的入口函数
"""

from multiprocessing import Process
from All_utils.gen_img_url import parse_HTML
from All_utils.http_aioget import HttpAioget
from All_utils.save_img import write_img

def http_get():
    # 实例化HttpAioget类的时候可以设定高速爬虫的并发量，默认100，建议设定500以下并发
    http_aioget = HttpAioget()
    http_aioget.run()


def write_image():
    write_img.run()


def gen_img_url():
    parse_HTML.gen_img_url()


def run():
    process_list = []

    p_http_get = Process(target=http_get)
    p_http_get.start()
    process_list.append(p_http_get)

    p_write_img = Process(target=write_image)
    p_write_img.start()
    process_list.append(p_write_img)

    p_gen_img_url = Process(target=gen_img_url)
    p_gen_img_url.start()
    process_list.append(p_gen_img_url)

    for each in process_list:
        each.join()


if __name__ == "__main__":
    run()

